<%@page import="com.windfone.common.SingleMailSend"%>
<%@page import="com.windfone.service.MemberService"%>
<%@page import="com.windfone.model.Order"%>
<%@page import="com.windfone.model.*"%>
<%@page import="com.windfone.common.Constant"%>
<%@ page language="java" contentType="text/html; charset=utf-8"    pageEncoding="utf-8"%>
<%@ include file="head.jsp" %>
<%@ taglib uri="/WEB-INF/recommend.tld" prefix="windfone" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>结账 风驰电讯  您最贴心的手机顾问 </title>
<%@ include file="headkey.jsp" %>
<script>
	function alipayFormSubmit(){
		var alipayForm = document.getElementById("alipayForm");
		alipayForm.submit();
	}
	function cncardFormSubmit(){
		var cncardForm = document.getElementById("cncardForm");
		cncardForm.submit();
	}
</script>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>

<body id="pages9">

<!--头部-->
 <%@ include file="navigate.jsp"%>
<!--内容-->
<div class="contentBox"><!--左区-->
<div class="col2" style="width:990px">
  <div class="tabLeBoxB" style=" padding-top:0">
  <div class="title">
    <h3>购物车</h3></div>
<div class="borderBox">
<div><img src="images/sopping4.gif" width="934" height="81" /></div>
<div style="width: 890px;" class="odb w985_p20">
			<div class="onum">请记录您的订单号：${receiveMsg.orderSeq }</div>
			<dl class="rec_1">
				<dd class="item1"><span class="black_b">收 货 人：</span> ${receiveMsg.name }</dd>
				<dd class="item1"><span class="black_b">详细地址：</span> ${receiveMsg.detailaddress }</dd>
				<dd class="item1"><span class="black_b">联系电话：</span>${receiveMsg.telnumber } &nbsp; ${receiveMsg.mobile } </dd>
				<dd class="item1"><span class="black_b">邮政编码：</span> ${receiveMsg.zipcode }</dd>
				<dd class="item1"><span class="black_b">配送方式：</span> 
				     <c:if test="${ receiveMsg.postType == 2 }"> 顺丰快递（<span class="red">运输费： 0.00元</span>）</c:if>
					<c:if test="${receiveMsg.postType == 1 }"> EMS 快递（<span class="red">运输费： 40.00元</span>）</c:if>
				</dd>
				<dd class="item2">
					<span class="black_b">支付类型：</span> 
					在线支付（<span class="red">手续费： 0.00元</span>）
				</dd>
			</dl>
			<dl class="rec_2">
				<dd class="item1">支付方式：</dd>
				<dd class="item2">
					<c:if test="${receiveMsg.payType == '1' }">
						<p>推荐一：云网在线支付 <font style="color: rgb(255, 0, 0);">免收手续费</font></p>
					</c:if>
					<c:if test="${receiveMsg.payType == '2' }">
						<p>推荐二：支付宝在线支付  <font style="color: rgb(255, 0, 0);">免收手续费</font></p>
					</c:if>
				</dd>
				<dd class="item1">备注：</dd>
				<dd class="item3">${receiveMsg.userMemo }</dd>
			</dl>
			<div class="floatend"></div>
			<div class="pd15"></div>
			<table>
				<tbody><tr>
					<th colspan="7">我购买的商品信息</th>
				</tr>
				<tr>
					<td class="center"><span class="black_b">商品类别</span></td>
					<td class="center"><span class="black_b">商品名称</span></td>
					<td class="center"><span class="black_b">属性</span></td>
					<td class="center"><span class="black_b">配件</span></td>
					<td class="center"><span class="black_b">单价</span></td>
					<td class="center"><span class="black_b">数量</span></td>
					<td class="center"><span class="black_b">小计</span></td>
				</tr>
				  <c:forEach var="mobile" items="${orderList}" varStatus="status"> 
				<tr>
					  <td class="center">
					  		<c:if test="${mobile.goodstype == 0 }">手机</c:if>
			  			<c:if test="${mobile.goodstype == 1 }">配件</c:if>
			  			</td>
					  <td class="center">
					  ${mobile.name }
					  </td>
					  <td class="center">
					  	<c:if test="${ mobile.colorName != null }">${ mobile.colorName }</c:if>
					  </td>
					  <td class="center">${mobile.standard}</td>
					  <td class="center">
					    <span class="green_b">¥${mobile.price }</span>
					  </td>
					  <td class="center">
					    <span class="red">${ mobile.orderNumber }</span>
					  </td>
					  <td class="center">
					    <span class="green_b">¥${mobile.price * mobile.orderNumber }</span>
					  </td>
					  <c:set var="total" value="${total+ (mobile.price * mobile.orderNumber)}"/>
				</tr>
				</c:forEach>
			</tbody></table>
			<div class="o_price">
				<span class="red">商品总额：</span><span style="padding-right: 20px;" class="red_b">￥${total }</span>
				<span class="red">附加总额：</span><span style="padding-right: 20px;" class="red_b">￥0.00</span>
				<span class="red">支付费率：</span><span style="padding-right: 20px;" class="red_b">￥0.00</span>
				<span class="red">配送费率：</span><span style="padding-right: 20px;" class="red_b">￥${receiveMsg.postcost }</span>
				<span class="red">积分兑换（0分）：</span><span class="red_b">￥0.00</span>
			</div>
			<div class="o_price"><span class="red">订单总额：</span><span style="font-size: 28px;" class="red_b">￥${receiveMsg.totalCost}</span></div>
			<div class="pd15"></div>
			<div style="text-align: center;">
				<div id="panOnline">
					订单已产生，请到<a href="memberCenter.action">会员中心</a>查看，然后在线付款
					
				<s:if test="receiveMsg.totalCost !=0 ">
					<s:if test="receiveMsg.payType==1">
						<form name="cncardForm" method="post" action="pay/cncard/Send.jsp" id="cncardForm" target="_blank">
						<a id="Online" title="点击进行在线支付"  href="#" >
							
							<input type="hidden" id="c_ymd"  name="c_ymd" value="<s:date  name='receiveMsg.createtime'  format="yyyyMMdd" />" />
							<%-- 
							<input type="hidden" id="c_orderamount"  name="c_orderamount" value="0.01" />
							--%>
							<input type="hidden" id="c_orderamount"  name="c_orderamount" value="${receiveMsg.totalCost}" />
							<input type="hidden" id="c_email"  name="c_email" value="${receiveMsg.email}" />
							<input type="hidden" id="c_name"  name="c_name" value="${receiveMsg.name}" />
							<input type="hidden" id="c_post"  name="c_post" value="${receiveMsg.zipcode}" />
							<input type="hidden" id="c_tel"  name="c_tel" value="${receiveMsg.mobile}" />
							<input type="hidden" id="c_address"  name="c_address" value="${receiveMsg.detailaddress}" />
							<input type="hidden" id="c_order"  name="c_order" value="${receiveMsg.orderSeq}" />
							<img src="images/os_img10.png" alt="立即到在线支付网站进行在线支付" onclick="cncardFormSubmit();return false;"/>
						</a>
						</form>
					</s:if>
					<s:if test="receiveMsg.payType==2">
						<form name="alipayForm" method="post" action="pay/alipay/alipayto.jsp" id="alipayForm" target="_blank">
							<input type="hidden" id="receive_mobile"  name="receive_mobile" value="${receiveMsg.mobile}" />
							<input type="hidden" id="receive_phone"  name="receive_phone" value="${receiveMsg.telnumber}" />
							<input type="hidden" id="zipcode"  name="zipcode" value="${receiveMsg.zipcode}" />
							<input type="hidden" id="receive_address"  name="receive_address" value="${receiveMsg.detailaddress}" />
							<input type="hidden" id="receive_name"  name="receive_name" value="${receiveMsg.name}" />
							<input type="hidden" id="logistics_fee"  name="logistics_fee" value="<c:if test='${ receiveMsg.postType == 1 }'>40.00</c:if><c:if test='${ receiveMsg.postType == 2 }'>0.00</c:if>" />
							<input type="hidden" id="logistics_type"  name="logistics_type"
							  value="<c:if test='${ receiveMsg.postType == 2 }'>EXPRESS</c:if><c:if test='${ receiveMsg.postType == 1 }'>EMS</c:if>"
							 />
							<input type="hidden" id="alimoney"  name="alimoney" value="${receiveMsg.totalCost}" />
							<input type="hidden" id="alibody"  name="alibody" value="${receiveMsg.userMemo}" />
							<%--
							<input type="hidden" id="alimoney"  name="alimoney" value="0.01" />
							--%>
							<input type="hidden" id="alipayGoodsName"  name="alipayGoodsName" value="${receiveMsg.allGoodsName}" />
							<input type="hidden" id="alipayOrderSeq"  name="alipayOrderSeq" value="${receiveMsg.orderSeq}" />
							<a id="Online" title="点击进行在线支付"  href="#" >
								<img src="images/os_img10.png" alt="立即到在线支付网站进行在线支付" onclick="alipayFormSubmit();return false;"/>
							</a>
						</form>
					</s:if>
				</s:if>					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
					
				</div>
			</div>
		</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
    <%@ include file="bottom.jsp" %>
    
 
<%
String sendStr = "您的订单号：";
com.opensymphony.xwork2.util.ValueStack vs = (com.opensymphony.xwork2.util.ValueStack)request.getAttribute("struts.valueStack");
ReceiveMsg  r = (ReceiveMsg) vs.findValue("receiveMsg");
java.util.List ls = (java.util.List) vs.findValue("orderList");
sendStr = sendStr  + r.getOrderSeq();
sendStr =sendStr + "\r\n" + "收 货 人:"+r.getName();
sendStr =sendStr + "\r\n" + "详细地址:"+r.getDetailaddress();
sendStr =sendStr + "\r\n" + "联系电话:"+r.getTelnumber()+"  "+r.getMobile();
sendStr =sendStr + "\r\n" + "邮政编码:"+r.getZipcode() ;
sendStr =sendStr + "\r\n" + "配送方式:"  ;
if ( r.getPostType().equals("2") ){
	sendStr =sendStr + "顺丰快递运输费： 0.00元";
} else {
	sendStr =sendStr +"EMS快递运输费： 40.00元";
}

sendStr =sendStr + "\r\n\r\n" + "我购买的商品信息";
sendStr =sendStr + "\r\n"+ " 商品类别	 	属性	 	配件	 	单价		 数量	 小计  "; 
double total = 0.0;
for(int i=0;i<ls.size();i++){
	Order o = (Order) ls.get(i);
	sendStr =sendStr + "\r\n";
	if ( o.getGoodstype() == 0){
		sendStr =sendStr + "手机  ";
	}
	if ( o.getGoodstype() == 1){
		sendStr =sendStr + "配件  ";
	}
	sendStr =sendStr + o.getName();
	if ( o.getColorName() != null ){
		sendStr =sendStr + o.getColorName()+"  ";
	} else {
		sendStr =sendStr  + "		"	;
	}
	sendStr =sendStr + o.getStandard()+"  ";;
	sendStr =sendStr + o.getPrice()+"  ";;
	sendStr =sendStr + o.getOrderNumber()+"  ";;
	
	sendStr =sendStr + (o.getPrice() * o.getOrderNumber())+"  ";
	total = total + ( o.getPrice() * o.getOrderNumber());
	
}
sendStr =sendStr + "\r\n\r\n"+ "商品总额："+ total;
sendStr =sendStr + "\r\n"+ "附加总额：￥0.00" ;
sendStr =sendStr + "\r\n"+ "支付费率：￥0.00" ;
sendStr =sendStr + "\r\n"+ "配送费率："+ r.getPostcost() ;
sendStr =sendStr + "\r\n"+ "积分兑换（0分）：￥0.00";
sendStr =sendStr + "\r\n"+ "订单总额："+r.getTotalCost();
/*
Object obj = session.getAttribute("userBean");
if ( obj !=null ){
	Member bean= (Member)obj;
	org.springframework.context.ApplicationContext springCtx=org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext( config.getServletContext() );
	MemberService memberService= (MemberService) springCtx.getBean("memberService");
	MemberDetail detailBean = memberService.getMemberDetailByKey(bean.getId());
	String email = detailBean.getEmail();
	System.out.println(  "email:"+email);
	SingleMailSend sm = new SingleMailSend();
	sm.setContent( sendStr	);
	sm.setToAddress( email	);
	sm.setTitle( "您在风驰电讯的订单"	);
	sm.send();
}
*/
try {
SingleMailSend sm = new SingleMailSend();
sm.setContent( sendStr	);
sm.setToAddress( r.getEmail()	);
System.out.println( r.getEmail());
sm.setTitle( "您在风驰电讯的订单"	);
sm.send();
}catch (Exception e){
	
}finally {
	
}
//System.out.println( sendStr );
%>
</body>
</html>
